package de.htwds.mada.todolistDB.model;

import java.io.Serializable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName="priority")
public class Priority implements Serializable {
	
	private static final long serialVersionUID = -6909096079249313493L;
	
	public static final String PRIO_ID_FIELD = "_id"; //primary key
	public static final String NAME_FIELD = "name";
	
	@DatabaseField(columnName = PRIO_ID_FIELD, generatedId = true)
	private int _id;
	
	@DatabaseField(columnName = NAME_FIELD, unique= true)
	private String name;
	
	public Priority() {}
	
	/**
	 *  Get id
	 *  
	 * @return	id
	 */
	public int getId() {
		return _id;
	}
	
	/**
	 * Get name
	 * 
	 * @return	name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Set new id value
	 * 
	 * @param id	new id value
	 */
	public void setId(int id) {
		this._id = id;
	}
	
	/**
	 * Set new name
	 * 
	 * @param name	new name
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Returns name
	 * 
	 * @return	name
	 */
	public String toString() {
		return name;
	}
	
	/**
	 * Returns the formated category name with id
	 * 
	 * @return	category name and id as formated string
	 */
	public String toStringComplete() {
		return "Name: "+name+", ID: "+_id;
	}
	
	/**
	 * Checks the id of the two objects
	 * 
	 * @return	true - only if the id is equals
	 */
	public boolean equals(Object priority){
		if(priority instanceof Priority)
			return this._id == ((Priority) priority).getId();
		else
			return false;
	}

}
